#include "udp_server.hpp"

using namespace ns_server;
using namespace std;

static void usage(string proc){
    cout << "Usage:\n\t" << proc << " port\n" << endl;
}

string transactionString(string request){
    string result;
    char c;
    for(auto& r : request){
        if(islower(r)){
            c = toupper(r);
            result.push_back(c);
        }
        else
            result.push_back(r);
    }
    return result;
}

int main(int argc, char* argv[]){
    if(argc != 2){
        usage(argv[0]);
        exit(USAGE_ERR);
    }
    uint16_t port = atoi(argv[1]);

    unique_ptr<UdpServer> usvr(new UdpServer(port, transactionString));

    usvr->InitServer();
    usvr->Recv();
    
    return 0;
}